/**
 * Anderground project - Subway maps processor application.
 * Copyright (C) 2008-2009 Eldar Abusalimov, Ilya Shurigyn
 * 
 * This file is part of Anderground.
 * 
 * Anderground is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * Anderground is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Anderground.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.anderground.core.drawer;

import org.anderground.core.Logger;

;

public class Property implements Cloneable {

	private String name;

	public enum Type {
		CHECKBOX, RADIOGROUP, DROPDOWN_LIST
	}

	private Type type;
	private String[] values;
	private String currentValue;

	public String getCurrentValue() {
		return currentValue;
	}

	public void setCurrentValue(String currentValue) {
		this.currentValue = currentValue;
	}

	public Property() {

	}

	public Property(String name, Type type, String[] value) {
		this.type = type;
		this.name = name;
		this.values = value;

	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Type getType() {
		return type;
	}

	public void setType(Type type) {
		this.type = type;
	}

	public String[] getValues() {
		int currentLocation = 0;
		for (int i = 0; i < values.length; i++) {
			if (values[i] == currentValue) {
				currentLocation = i;
				break;
			}
		}
		String temp = values[currentLocation];
		values[currentLocation] = values[0];
		values[0] = temp;

		return values;
	}

	public void setValues(String[] value) {
		this.values = value;
	}

	public boolean getBooleanValue() {
		boolean b;
		if (this.currentValue == "true") {
			b = true;
		} else {
			b = !true;
		}
		return b;
	}

	@Override
	public Object clone() {
		Object clone = this;
		try {
			clone = super.clone();
		} catch (CloneNotSupportedException e) {
			Logger.log(e);
		}
		return clone;
	}

}
